package com.gufe.controller.user.message;

import com.gufe.dto.message.MsgListDTO;
import com.gufe.result.Result;
import com.gufe.service.user.message.MessageService;
import com.gufe.vo.message.MsgListVO;
import com.gufe.vo.message.MsgUserListVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("UserMessageController")
@Slf4j
@RequestMapping("/api/user/message")
public class messageController {

    @Autowired
    MessageService messageService;

    //获取聊天记录
    @GetMapping("/msgs")
    public Result<List<MsgListVO>> getMsgList(MsgListDTO msgListDTO){
        log.info("获取聊天记录；userId:{}，chatId：{}",msgListDTO.getUserId(),msgListDTO.getChatId());
        List<MsgListVO> msgListVOS = messageService.getMsgList(msgListDTO);
        return Result.success(msgListVOS);
    }

    //获取聊天对象表
    @GetMapping("/msgUserList")
    public Result<MsgUserListVO> getMsgUserList(Long userId){
        log.info("获取消息聊天列表");
        MsgUserListVO msgUserListVO = messageService.getMsgUserList(userId);
        return Result.success(msgUserListVO);
    }
}
